//TEllipse03.cpp
#include "TEllipse03.h"
#include <iostream>
TEllipse::TEllipse(uint longR, uint shortR, 
                       uint x, uint y):TShape(x,y){
    _longR  = longR;
    _shortR = shortR;
    //在派生类构造函数中初始化基类保护成员
    _RED    = 0x00;
    _GREEN = 0x00;
    _BLUE  = 0xa0;
    std::cout << "TEllipse construted with color (";
    std::cout<<static_cast<uint>(_RED)   <<","
               <<static_cast<uint>(_GREEN)<<","
               <<static_cast<uint>(_BLUE) <<")"<<std::endl;
}
TEllipse::~TEllipse(){
    std::cout << "TEllipse destruted." <<std::endl;
}
void TEllipse::Draw(){
    uint x, y;
    getXY(x, y);       //调用基类函数获取椭圆的圆心坐标
    std::cout<<"Draw an ellipse with color(";
    std::cout<<static_cast<uint>(_RED)   <<","
               <<static_cast<uint>(_GREEN)<<","
               <<static_cast<uint>(_BLUE) <<") at point(";
    //  cout<<_x<<", "<<_y<<") "<<endl; //错误！在派生类中不能访问基类私有成员
    std::cout << x << ", " << y << "), longR: ";
    std::cout << _longR << " and shortR: " << _shortR << std::endl;
}

int main() {
    TEllipse elps(10u, 5u, 20u, 30u);
    // elps.setRGB(0x00, 0x00, 0xff);
    //elps._RED=0x10;//错误！派生类对象不能访问基类的保护成员
    elps.Draw(); 
    return 0;
}


